package graphics.object;

import graphics.GLObjectManager.RenderPriority;
import graphics.TestingGraphics;

public class GLTextRectangle extends GLRectangle{

	private static final long serialVersionUID = 1L;
	
	public String text;
	
	public GLTextRectangle(String text, int x, int y){
	    super(x, y, TestingGraphics.font.getWidth(text), TestingGraphics.font.getHeight(text));
	    setText(text);	
	    setRenderPriority(RenderPriority.LOWEST);
	}
	
	public String getText(){
	    return text;
	}
	
	public void setText(String newText){
	    text = newText;
	    width = TestingGraphics.font.getWidth(text);
	    for(String a:text.split("\n")){
	    	if(width < TestingGraphics.font.getWidth(a)){
	    		width = TestingGraphics.font.getWidth(a);
	    	}
	    }
        height = TestingGraphics.font.getHeight(text);
	}
	
	public void onRender() {
		TestingGraphics.font.drawString(x, y, text);
	}
}
